{% extends 'admin/index.html' %}


{% block con-title%}
    <div class="container-fluid am-cf">
        <div class="row">
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                <div class="page-header-heading">
                    <span class="am-icon-home page-header-heading-icon">用户组添加</span>
            
        </div>
    </div>

{% endblock %}
{% block con-body %}
    <div class="row-content am-cf">
        <div class="row  am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-body am-fr">
                            <form action="{% url 'admin_authgroupadd' %}" method='post' id="uploadForm" enctype="multipart/form-data" class="am-form tpl-form-line-form">
                                {% csrf_token %}
                                <div class="am-form-group">
                                    <label  for="user-name" class="am-u-sm-3 am-form-label" >组名</label>
                                    <div class="am-u-sm-9">
                                        <input name='name' name='username' required maxlength="50" type="text" class="tpl-form-input" id="user-name" placeholder="请输入您的组名">
                                    </div>   
                                </div>
                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">设置权限</label>
                                    <div class="am-u-sm-9">
                                        <div class="am-u-sm-5" class="select">
                                            <center><p>可选的权限</p></center>
                                            <select multiple="multiple" class="one">
                                                {% for v in olist %}
                                                <option value="{{ v.id }}">{{v.name}}</option>
                                                {% endfor %}
                                            </select>
                                            <br>
                                            <center>
                                            <button type="button" class="btn-all am-btn am-btn-primary am-btn-xs">选择全部-> </button>
                                            </center>
                                        </div>
                                        <div  class="am-u-sm-5">
                                            <center><p>已选的权限</p></center>
                                            <select multiple="multiple" class="two" name="prms">
                                                


                                            </select>
                                            <br>
                                            <center>
                                            <button type="button" class="btn-remove am-btn am-btn-danger am-btn-xs"> <- 移除权限 </button>
                                            </center>   

                                        </div>
                                    </div>
                                </div>
                              
                                

                                

                                
                                
                                 
                                <div class="am-form-group">
                                    <div class="am-u-sm-9 am-u-sm-push-3">
                                        <button id="sb" class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button></div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<script src="/static/admin/js/bootstrap-fileinput.js">
    

</script>
<script type="text/javascript">
    
    $('.one option').dblclick(function(){
        $('.two').append($(this))
        $(this).attr('selected',false)
    })
    $('.two').on('dblclick','option',function(){
        $('.one').append($(this))
        $(this).attr('selected',false)

    })
    $('.btn-all').click(function(){

        var a = $(this).parents('div').find('option')
        $('.two').append(a)
    }) 
    $('.btn-remove').click(function(){
        var a = $(this).parents('div').find('option')
        $('.one').append(a)

    }) 
  //绑定提交事件
    $('#sb').click(function(){

        $('.two option').prop('selected',true)
    }) 
</script>

{% endblock %}